export const keys = {
  material: '材料',
  rohs: 'RoHS',
  mass: '产品重量',
  keykind: '钥匙种类',
  nankin: '挂锁',
  pitch: '安装距离',
  diameter: '直径',
  pin: '销子',
  length: '长',
  width: '宽',
  thick: '板厚',
  hole: '孔',
  offsethimax: '偏置高度',
  door: '上推行程',
  horizontal: '水平位置',
  removal: '上推',
  maxlength: '全长',
  keyno: '钥匙编号',
  lockkind: '锁种类',
  adjust: '调节',
  power: '保持力（N)',
  differ: '单配钥匙数量',
  maxtemp: 'max温度',
  mintemp: 'min温度',
  volt: '额定电压',
  ratingtype: '通电时',
  locktype: '锁样式',
  wheelmaterial: '车轮的材质',
  onheight: '安装高度',
  allowload: '容许荷载(N)',
  shaftdiameter: '轴径',
  totallength: '全长',
  shaftlength: '调整范围',
  stroke: '行程',

  name: '产品名',
  icon: 'icon',
  pdfimage: 'PDF图片',
  pdf: 'PDF文件',
  pdfbook: '电子书地址',
  movie: '视频地址',
  features: '特点',
  specifications: '规格',
  specificUse: '特殊用途',
  remarks: '备注',
  gremarks: 'gremarks',
  dxf: '2D.DXF',
  sat: '3D.SAT',
  step: '3D.STEP',
  x_t: '3D.X_T',
  igs: '3D.IGS'
}

export function handleSubmitData (data) {
  let { features, specifications, specificUse, remarks } = data
  features && (features = plain2Html(features))
  specifications && (specifications = plain2Html(specifications))
  specificUse && (specificUse = plain2Html(specificUse))
  remarks && (remarks = plain2Html(remarks))
  return { features, specifications, specificUse, remarks }
}

export function html2Plain (str) {
  const removeTagReg = /<[^>]+>/g
  const plain = str.replace(/<br>/g, '\n...').replace(removeTagReg, '|')
  return plain.split('||').filter(v => v).join('\n')
}
export function plain2Html (plain) {
  // \\ 间隔
  const ps = plain.replace(/\n\.{3}/g, '<br>').split('\n')
  let html = `<ul class="List List__Normal">`
  ps.forEach(p => {
    if (p.length) {
      html += `<li>${p}</li>`
    }
  })
  return html + '</ul>'
}
